package cn.com.cifi.mars.web.action.report;

import cn.com.cifi.mars.common.bean.R;
import cn.com.cifi.mars.common.constants.VersionConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;

@Api(tags = "报表API")
@RequestMapping("/${spring.data.rest.base-path}/{apiVersion}/report")
public interface IAnalyticalReportController {

    @ApiOperation(value = "手动刷新供销综合分析底表", notes = "刷新dm_dm_plan_sign_year表、dm_dm_plan_sign_month表数据\n"+
            "v1 : 指定年月,全量刷新\n" +
            "v2 : 指定年月,指定项目,刷新")
    @GetMapping(value = "refreshdmAnalytical")
    R refreshdmAnalytical(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
            @ApiParam(value = "项目Id", required = false) @RequestParam(value = "projectId",required = false) String projectId,
            @ApiParam(value = "年月", required = true) @RequestParam String yearMonth);

    @ApiOperation(value = "手动刷新指定时间供销分析表中项目层级及以下数据", notes = "手动刷新指定时间供销分析表中项目层级及以下数据\n"+
            "v1 : 全量刷新\n" +
            "v2 : 指定年月刷新")
    @GetMapping(value = "refreshProjectDmAnalytical")
    R refreshProjectDmAnalytical(String apiVersion, String yearMonth);

    @ApiOperation(value = "查询供销综合分析表", notes = "查询供销综合分析表")
    @GetMapping(value = "dmAnalytical")
    R dmAnalytical(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
            @ApiParam(value = "截止年月", required = true) @RequestParam String ofYearMonth,
            @ApiParam(value = "历史年份", required = true) @RequestParam String year);

    @ApiOperation(value = "供销综合分析表导出", notes = "供销存综合分析表导出")
    @GetMapping(value = "dmAnalyticalExport")
    void dmAnalyticalExport(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
            HttpServletResponse response,
            @ApiParam(value = "年月", required = true) @RequestParam String yearMonth);
}
